package lec09.pm;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class LoginTest {
	static Map<String, String> users = new HashMap<>();

	static {
		try {
			Scanner cin = new Scanner(new File("users.txt"));
			while (cin.hasNextLine()) {
				String line = cin.nextLine().trim();
				if (line.isEmpty())
					continue;
				String ss[] = line.split("\\s+");
				users.put(ss[0].toLowerCase(), ss[1]);
			}
			cin.close();
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	static boolean check(String userName, String password) {
		return users.containsKey(userName)&&
				users.get(userName).equals(password);
	}

	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while (cin.hasNext()) {
			String userName = cin.next();
			String password = cin.next();
			if (check(userName, password))
				System.out.println("Welcome " + userName + "!");
			else
				System.out.println("Login failed!");
		}
		cin.close();
	}
}
